﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace cds_betadev01.source
{
    class ObjDisplay :Obj
    {
       
        private Model model;
        public ObjDisplay()
        {
            
        }
        public void setModel(Model mmodel, float sscale,Vector3 rrot, Vector3 ttr)
        {
            model = mmodel;
            base.init(ttr, sscale, rrot);
        }
        virtual public void init(Vector3 position, float scale, Vector3 rot,Model mmodel)
        {
            base.init(position, scale, rot);
            model = mmodel;

        }
        virtual public void draw(Matrix View,Matrix Projection)
        {
            Matrix[] transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World = transforms[mesh.ParentBone.Index] * World;

                    // Use the matrices provided by the  camera
                    effect.View = View;
                    effect.Projection = Projection;
                }
                mesh.Draw();
            }
        }
        
    }
}
